package com.ljkj.blockpay.ui.adapter;

import static com.ljkj.blockpay.ui.activity.TradingParticularsActivity.conventDateStrByPattern;

import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.kongzue.baseokhttp.util.JsonList;
import com.ljkj.blockpay.R;
import com.ljkj.blockpay.model.TimeModel;

import java.util.Date;
import java.util.List;

/**
 * Created by yp on 2022/3/23  历史记录
 */
public class HistoryListAdapter extends BaseQuickAdapter<TimeModel.DataTimeModel, BaseViewHolder> {

    private String  time;;

    public HistoryListAdapter(int layoutResId, @Nullable List<TimeModel.DataTimeModel> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder baseViewHolder, TimeModel.DataTimeModel jsonList) {

        Glide.with(getContext()).load(jsonList.getHeadUrl()).into((ImageView) baseViewHolder.getView(R.id.iv_icon));
        if (jsonList.getOrderType() == 1){
            baseViewHolder.setText(R.id.tv_title,"充值");
            baseViewHolder.setText(R.id.tv_number,jsonList.getOriginAmount());
        } else if (jsonList.getOrderType() == 2){
            if (jsonList.isFromMe() == true){
                baseViewHolder.setText(R.id.tv_title,"转给"+jsonList.getTargetAccount());
                baseViewHolder.setText(R.id.tv_number,jsonList.getOriginActualAmount());
            } else {
                baseViewHolder.setText(R.id.tv_title,"来自"+jsonList.getOriginAccount());
                baseViewHolder.setText(R.id.tv_number,jsonList.getTargetActualAmount());
            }

        } else if (jsonList.getOrderType() == 3){
            baseViewHolder.setText(R.id.tv_title,"提币");
            baseViewHolder.setText(R.id.tv_number,jsonList.getOriginActualAmount());
        } else if (jsonList.getOrderType() == 4){
            if (jsonList.isFromMe()==true){
                baseViewHolder.setText(R.id.tv_title,"扫码付给"+jsonList.getTargetAccount());
                baseViewHolder.setText(R.id.tv_number, jsonList.getOriginActualAmount());
            } else {
                baseViewHolder.setText(R.id.tv_title,"来自"+jsonList.getOriginAccount()+"的扫码付");
                baseViewHolder.setText(R.id.tv_number,jsonList.getTargetActualAmount());
            }
        } else if (jsonList.getOrderType() == 5){
            baseViewHolder.setText(R.id.tv_title,"兑换");
//            baseViewHolder.setText(R.id.tv_number, "-"+jsonList.getOriginActualAmount());
//            baseViewHolder.setText(R.id.tv_number, "+"+jsonList.getTargetActualAmount());
        }
        long l = Long.parseLong(jsonList.getCreateTime());
        time = conventDateStrByPattern(new Date(l), "yyyy-MM-dd HH:mm:ss");
        baseViewHolder.setText(R.id.tv_date,time);



    }
}
